<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="zh-CN">
<head>
    <meta charset="GB18030">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/carousel.css">
    <style>
        .tree li {
            list-style-type: none;
            cursor: pointer;
        }

        table tbody tr:nth-child(odd) {
            background: #F4F4F4;
        }

        table tbody td:nth-child(even) {
            color: #C00;
        }

        th {
            text-align: center
        }
        .xxspan {
            display: none;
            color: #d43f3a;
        }
    </style>
</head>

<body>
<div class="navbar-wrapper ">
    <%--动态导入另一个jsp页面，作用：将公共使用的部分提取出来，然后使用动态导入
              动态导入是不会导入include页面的编译指令的，而是仅仅将被导入页面的body内容插入本页面。--%>
    <jsp:include page="admin-header.jsp"></jsp:include>
</div>
<div class="container-fluid">
    <div class="row">
        <%--动态导入另一个jsp页面，作用：将公共使用的部分提取出来，然后使用动态导入
                  动态导入是不会导入include页面的编译指令的，而是仅仅将被导入页面的body内容插入本页面。--%>
        <jsp:include page="admin-left.jsp"></jsp:include>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="glyphicon glyphicon-th"></i> 新增文章</h3>
                </div>
                <div class="panel-body">
                    <form id="addEssay" class="form-horizontal" role="form" action="/tbEssay/addEssay" method="post"
                          enctype="multipart/form-data">
                        <div class="form-group ">
                            <label>
                                文章标题
                                <span class="xxspan" id="sp">必填</span></label>
                            <input  name="essayTitle" type="text" maxlength="255" id="essayTitle"
                                   class="form-control"
                                   placeholder="请输入...."/>
                        </div>

                        <div class="form-group ">
                            <label>
                                作者
                                <span class="xxspan" id="sp1">必填</span></label>
                            <input name="essayAuthor" type="text" value="" maxlength="50" id="essayAuthor"
                                   class="form-control form_datetime" placeholder="请输入...."/>
                        </div>
                        <div class="form-group ">
                            <label>
                                文章简介
                                <span class="xxspan" id="sp2">必填</span></label>
                            <input name="essayBrief" type="text" value="" maxlength="50" id="essayBrief"
                                   class="form-control form_datetime" placeholder="请输入...."/>
                        </div>
                        <div class="form-group ">
                            <label>
                                文章内容
                                <span class="xxspan" id="sp3">必填</span></label>
                            <textarea name="essayContent" rows="10" cols="20" id="essayContent"
                                      class="form-control form_datetime">
</textarea>
                        </div>
                        <div class="form-group ">
                            <label>
                                文章来源
                                <span class="xxspan" id="sp4">必填</span></label>
                            <input name="essaySource" type="text" maxlength="50" id="essaySource"
                                   class="form-control form_datetime" placeholder="请输入...."/>
                        </div>
                        <div class="form-group ">
                            <label>
                                配图1</label>
                            <input name="file1" type="file"/>
                        </div>
                        <div class="form-group ">
                            <label>
                                配图2</label>
                            <input name="file2" type="file"/>
                        </div>
                        <div class="form-group ">
                            <label>
                                配图3</label>
                            <input name="file3" type="file"/>
                            <p class=" help-block">
                                您可选择故障照片上传,只允许上传 .jpg, .jpeg, .gif, .png, .bmp 格式图片！</p>
                        </div>
                        <div class="form-group ">
                            <label>
                                文章类型</label>
                            <br/>
                            <select class="form-control" id="essayType" name="essayType">
                                <option value="1">电脑入门</option>
                                <option value="2">常见故障</option>
                                <option value="3">IT资讯</option>
                            </select>
                        </div>
                        <div class=" form-group">
                            <input id="addInt" type="submit" class="btn btn-primary" value="提交"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div> <!-- /container -->
</div>
<script src="${pageContext.request.contextPath}/resources/jquery/jquery-2.1.1.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/script/docs.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/script/back-to-top.js"></script>

</body>
<script>
    $(function () {

        $("[data-toggle='tooltip']").tooltip();

        $(".list-group-item").click(function () {
            if ($(this).find("ul")) {
                $(this).toggleClass("tree-closed");
                if ($(this).hasClass("tree-closed")) {
                    $("ul", this).hide("fast");
                } else {
                    $("ul", this).show("fast");
                }
            }
        });
        $('input').focus(function () {
            $('input').css("border-color", "#CCC");
        });

        $('#addInt').click(function panduan() {
            console.log($("#essayTitle").val().length);
            //判断不能为空
            if ($("#essayTitle").val() == "") {
                $("#essayTitle").css("border-color", "red");
                $('#sp').show();
                return false;
            } else {
                $('#sp').attr("display", 'none');
            }
            //判断不能为空
            if ($("#essayAuthor").val() == "") {
                $("#essayAuthor").css("border-color", "red");
                $('#sp1').show();
                return false;
            } else {
                $('#sp1').attr("display", 'none');
            }
            //判断不能为空
            if ($("#essayBrief").val() == "") {
                $("#essayBrief").css("border-color", "red");
                $('#sp2').show();
                return false;
            } else {
                $('#sp2').attr("display", 'none');
            }
            //判断不能为空
            if ($("#essayContent").val() == "") {
                $("#essayContent").css("border-color", "red");
                $('#sp3').show();
                return false;
            } else {
                $('#sp3').attr("display", 'none');
            }
            //判断不能为空
            if ($("#essaySource").val() == "") {
                $("#essaySource").css("border-color", "red");
                $('#sp4').show();
                return false;
            } else {
                $('#sp4').attr("display", 'none');
            }
            //用来判断负责人是否添加成功

            var addLeaderStatus = '<%=session.getAttribute("addLeaderStatus")%>';

            var addLeaderStatus2 = '${addLeaderStatus2}';
            //alert(addLeaderStatus + "++++++=====" + addLeaderStatus2);
            if (addLeaderStatus == "001" || addLeaderStatus == 1) {
                alert("添加成功")
            }
            if (addLeaderStatus2 == 0) {
                alert("负责人已存在，请重新添加")
            }
        })


    })
</script>
</html>
